package com.kangkang.creationalpattern;

public class Singleton4 {
    /*
     * 懒汉式创建单例模式 由于懒汉式是非线程安全，双重效验锁
     */
    private volatile static Singleton4 singleton;

    private Singleton4() {
    }

    public static Singleton4 getInstance() {
        if (singleton == null) {
            synchronized (Singleton4.class) {
                if (singleton == null) {
                    singleton = new Singleton4();
                }
            }
        }
        return singleton;
    }

}
